/*
 * Copyright (C) 2022 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package cn.kcrx.autoweightapp.fragment

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import cn.kcrx.autoweightapp.R
import cn.kcrx.autoweightapp.core.BaseFragment
import cn.kcrx.autoweightapp.databinding.FragmentSettingUpdateBinding
import com.xuexiang.xpage.annotation.Page
import com.xuexiang.xpage.base.XPageFragment
import com.xuexiang.xpage.enums.CoreAnim
import com.xuexiang.xui.utils.ResUtils
import com.xuexiang.xupdate.XUpdate
import com.xuexiang.xutil.app.AppUtils

@Page(name = "版本升级", anim = CoreAnim.none)
class SettingUpdateFragment: BaseFragment<FragmentSettingUpdateBinding>() {
    val mUpdateUrl = "http://60.205.105.230:6999/chfs/shared/AutomaticWeighting/kcrxepmsrsupdate_api.json"

    override fun initViews() {
       binding!!.tvContent.text="当前版本号:V${AppUtils.getAppVersionName()}"
        XUpdate.newBuild(requireContext())
            .updateUrl(mUpdateUrl)
            .promptThemeColor(ResUtils.getColor(R.color.colorPrimary))
            .promptButtonTextColor(ResUtils.getColor(R.color.cardview_light_background))
            .promptTopResId(R.drawable.update_bg_app_top)
            .promptWidthRatio(0.7F)
            .update()
    }

    override fun viewBindingInflate(
        inflater: LayoutInflater,
        container: ViewGroup
    ): FragmentSettingUpdateBinding =FragmentSettingUpdateBinding.inflate(inflater,container,false)

}
